<? foreach($cats as $category): ?>

<table class="home">

	<tr>
		<th class="cat_name" id="<?= $category['id'] ?>">
			<?= $category['name'] ?>
		</th>
		{admin}
			<th class="delete">
				<?= anchor('category/admin/delete/'.$category['id'], 'Delete', array('class' => 'admin delete_confirm'))?>
			</th>
		{/admin}
	</tr>
	
	<tr><td colspan="2">
	
		<table border="0" class="single_category">
			<tr class="subheader">
				<td class="name">Forum</td>
				<td {admin}colspan="2"{/admin}>Latest Post</td>
			</tr>
			<? foreach ($this->Forum->get_forums($category['id']) as $forum): ?>
				<? if ($forum == -1 ): ?>

					<tr class="single_forum">
						<td colspan="2" style="width: 50em; padding: 1em">
							There are no forums in this category.
						</td>
					</tr>
		
				<? else: ?>

					<tr class="single_forum">
						<td class="name">
							<?= anchor('forum/view/'.$forum['id'], $forum['name']) ?>
							<br/>
							<small class="forum_description" id="<?= $forum['id'] ?>"><?= $forum['description'] ?></small>
						</td>
						<td class="latest" {not_admin}style="width: 27.5em"{/not_admin}>
							<? if($forum['newest_time'] != 0): ?>
								Last Post:<br/>
									<?= anchor('topic/view/'.$forum['newest_id'], mdate('%d %F %h:%i %A', gmt_to_local($forum['newest_time'], $this->_user['timezone'], $this->_user['daylight_savings'])) ) ?>
							<? else: ?>
								Forum is empty
							<? endif; ?>
						</td>
						{admin}
						<td class="delete"><?= anchor('forum/admin/delete/'.$forum['id'].'/'.$category['id'], 'X', array('class' => 'admin delete_confirm'))?></td>
						{/admin}
					</tr>

				<? endif; ?>
			<? endforeach; ?>
		</table>

	</td></tr>

	{admin}
	<tr><td colspan="2" class="add_forum">
		<?= anchor('forum/admin/add/'.$category['id'], 'Add Forum', array('class' => 'admin'))?>
	</td></tr>
	{/admin}

</table>

<? endforeach; ?>

{admin}
<?= anchor('category/admin/add', 'Add a category', array('class' => 'admin')) ?>
{/admin}

{admin_box}
{/admin_box}